#define pi 3.1415926535

const int Nx = 192;
const int Ny = 256;
const double Rmin = 3.229621;
const double Rmax = 5.229621;
const double Zmin = -1.599856;
const double Zmax = 1.599856;
const double dr = 0.010471;
const double dz = 0.012548;

const double qmr = 10.0; // charge mass ratio

struct vec
{
    double x, y ,z;
};

void loadfield(double field[Nx*Ny], const char* str);

double interp(double r, double z, double field[Nx*Ny]);
bool checkboundary(vec vp);
void diagnose(vec vp, vec vv);
vec vectorfield(vec vp);
void output(vec* vparr, vec* vvarr, double* vfreq, int N, const char* str);

vec cross(vec a, vec b);
double dot(vec a, vec b);
vec operator+(vec a, vec b);
vec operator*(double a, vec x);

void initdata(vec* vap, vec* vav, int N);
void initdata_passing(vec* vap, vec* vav, int N);
vec vectorfield(vec vp);
void diagnose(vec vp, vec vv, char mode);